/**
 * 页面定制公共事件
 */
import {onMounted, onUnmounted} from 'vue';
export default {
    created(){
        onMounted(() => {
            let self=this;
            /**
             * 页面定制公共事件
             */
            this.$eventBus.$on('formCustomViewEvent', (conf)=> {
                for (let i = 0; i < self.layout.length; i++) {
                    let layout=self.layout[i];
                    if(!layout.config){
                        return;
                    }
                    if(!self.$refs[layout.id]){
                        return;
                    }
                    let control=self.$refs[layout.id][0];
                    //触发组件中的公共事件
                    if(control && control.$refs[layout.config.alias] && control.$refs[layout.config.alias].handPublicReceive){
                        control.$refs[layout.config.alias].handPublicReceive(conf);
                    }
                }
            });
        });
        onUnmounted(() => {
            //销毁事件
            this.$eventBus.$off("formCustomViewEvent");
            this.$eventBus.$off("changeTree");
        });
    },
}
